<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="com.wzw.tcjh.PageDivision"%>
<%@page import="com.wzw.ad.ADTools"%>
<%@page import="com.wzw.ad.Adposition"%>
<%@page import="com.wzw.util.ProjectCode"%>
<% int pageSize = 10; %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>媒体广告位管理</title>
    <link href="css/ADposition.css" rel="stylesheet" type="text/css" />
    <link href="css/jquery-ui-1.8.17.custom.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="Scripts/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="Scripts/jquery-ui-1.8.17.custom.min.js"></script>
    <script type="text/javascript" src="Scripts/ajax.js"></script>
    <script type="text/javascript" src="Scripts/ADposition.js"></script>
  </head>
<% 
	if(session.getAttribute("user")==null || session.getAttribute("projectCode")==null){
		response.sendRedirect("login.jsp");
		return;
	}
	//page division part(top)
	int currentPage = 1;
	String currentPageString = request.getParameter("currentPage");
	String pcode = (String)session.getAttribute("projectCode");
	String serverBase = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();
	String projectUrl = serverBase + ProjectCode.getProjectCode(pcode).getUrl();
	if(currentPageString!=null&&!"".equals(currentPageString)) {
		currentPage = Integer.parseInt(currentPageString);
	}
	StringBuffer searchSQL = new StringBuffer();
	searchSQL.append("and projectcode = '" + pcode + "'");
	String countSql = "select ad_id from adposition where projectcode='" + pcode + "'" + (searchSQL.length()>0?searchSQL.toString():"");
	PageDivision pd = new PageDivision(currentPage, pageSize, countSql);
	List<Adposition> adList = ADTools.getADList((searchSQL.length()>0?searchSQL.toString():"") + " order by m_id asc, ad_id asc", pd);
%>
    <script type="text/javascript">
    projectCode = <%=pcode%>;
    projectUrl = "<%=projectUrl%>";
    </script>
<body>
  <jsp:include page="/adminNav.jsp" />
  <div class="div_title"><b>媒体广告位管理</b></div>
  <div class="div_mediaTable">
    <ul class="ul_row ul_row_title">
      <li class="li_mediaAd">媒体</li>
      <li class="li_mediaAd">广告位</li>
      <li class="li_operation li_operation1">操作</li>
      <li class="li_operation li_operation2">参与数/点击数</li>
    </ul>
<%
	int iRecord = 1;
	for(Adposition adPosition:adList) {
%>
    <ul id="adRecord<%=iRecord %>" class="ul_row" onmouseover="onMouseOverRecord(this.id)" onmouseout="onMouseOutRecord(this.id)">
      <li class="li_mediaAd"><label><%=adPosition.getMediaName() %></label></li>
      <li class="li_mediaAd"><label><%=adPosition.getADName() %></label></li>
      <li class="li_operation"><a href="#" onclick="deleteADPosition(<%=adPosition.getADId() %>)">删除</a></li>
      <li class="li_operation"><a href="#" onclick="editADPositionClick(<%=adPosition.getADId() %>)">编辑</a></li>
      <li class="li_operation li_operation2"><label><%=adPosition.getRegisterCount() %> / <%=adPosition.getHitCount() %></label></li>
    </ul>
<%
		iRecord++;
	}
	if(iRecord <= pageSize+1) {
		for(int i=iRecord;i <= pageSize+1; i++) {
			if(i == iRecord) {
%>
	<ul id="adRecord<%=i %>" class="ul_row ul_new ul_new_first" onclick="addNewRecord()" onmouseover="onMouseOverNewRecord(this.id)" onmouseout="onMouseOutNewRecord(this.id)">
	</ul>
<%
			}
			else {
%>
	<ul id="adRecord<%=i %>" class="ul_row ul_new">
	</ul>
<%
			}
		}
	}
%>
  </div>
  <div class="div_divisionPage">
<%
	//page division part(bottom)
	if(pd!=null&&pd.getTotalPage()>1){
%>
	<span><% pd.showPageList(out, "ADposition.jsp?currentPage=");%></span>		
<% 
	}
%>
  </div>
  
  <!-- 新增或编辑广告位信息Dialog界面 -->
  <div id="divDetail" style="display:none">
    <ul id="ul_adDetail">
      <li class="li_adItem">
        <span class="sp_detailName">媒体：</span>
        <select class="adInfo" id="selMedia"></select>
        <a class="a_mediaAdd" href="#" id="btnAddNewMedia" onclick="newMediaClick()">新增</a>
      </li>
      <li class="li_adItem">
        <span class="sp_detailName">广告位：</span>
        <input class="adInfo" id="txtAdPosition" type="text" />
      </li>
      <li class="li_adItem">
        <span class="sp_detailName">URL地址：</span>
        <input class="adInfo" id="txtFromUrl" type="text" />
      </li>
      <li class="li_adItem">
        <span class="sp_detailName">点击数：</span>
        <input class="adInfo" id="txtHitCount" type="text" value="0" />
      </li>
      <li class="li_adItem">
        <span class="sp_detailName">参与数：</span>
        <input class="adInfo" id="txtRegisterCount" type="text" value="0" />
      </li>
    </ul>
  </div>
  
  <!-- 新增媒体Dialog界面 -->
  <div id="divNewMedia" style="display:none">
    <span>媒体名称：</span>
    <input class="" id="txtNewMediaName" type="text">
  </div>
</body>
</html>


